﻿<%@ Page AutoEventWireup="true" CodeFile="UploadFile.aspx.cs" Inherits="Task_UploadFile"
    Language="C#" MasterPageFile="Task.master" StylesheetTheme="Content" Title="Untitled Page" %>

<asp:Content ID="Content1" runat="Server" ContentPlaceHolderID="ContentPlaceHolder1">

    <script src="../Scripts/jquery.js" type="text/javascript"></script>

    <script src="../Scripts/interface.js" type="text/javascript"></script>

    <script type="text/javascript">
	
 	$(document).ready(function(){ 		 
 		 for(var i=0;i<5;i++)
 		 {
 		    uploadcreate($("#uploadbox"),i);
 		 }
	});
 	
 	var hideDiv = function(idName){
 		$("#"+idName).fadeOut("fast");
 	};
 	
 	//是否显示上传后的图片
 	var isshowpic = false;  
 	var uploadshowpic = function(el){
 	    isshowpic = !(isshowpic);
 	    if(isshowpic)
 	    {
 	        el.html("图片显示关闭");
 	    }
 	    else
 	    {
 	        el.html("图片显示开启");
 	    }
 	};
 	
 	//载入中的GIF动画
    var loadingUrl = "../images/ajax-loader.gif";
    
    //选择文件后的事件,iframe里面调用的
    var uploading = function(imgsrc,itemid){
        var el = $("#uploading"+itemid);
        $("#ifUpload"+itemid).fadeOut("fast");
        el.fadeIn("fast");
	    el.html("<img src='"+loadingUrl+"' align='absmiddle' /> 上传中...");
	    return el;
    };
    
    //上传时程序发生错误时，给提示，并返回上传状态
    var uploaderror = function(itemid){
        alert("程序异常，"+itemid+"项上传未成功。");
        uploadinit();
    };
    
    //上传成功后的处理
	var uploadsuccess = function(newpath,itemid,objname){
        $("#uploading"+itemid).html(objname+"文件上传成功。");
        if(isshowpic)
        {
            $("#panelViewPic"+itemid).html("<a href='"+newpath+"' title='点击查看大图' target='_blank'><img src='"+newpath+"' alt='' style='width:300px;' /></a>");        
            $("#panelViewPic"+itemid).fadeIn("fast");
        }
    };
    
    
    var currentItemID = 0;  //用于存放共有多少个上传控件了
    //创建一个上传控件
    var uploadcreate = function(el,itemid){
        currentItemID ++;
        if(itemid == null)
        {
            itemid = currentItemID;
        }  
        var strContent = "<div class='uploadcontrol'><iframe src=\"upload.aspx?id="+itemid+"&objid=<% =objId %>&Flag=<% =flag %>\" id=\"ifUpload"+itemid+"\" frameborder=\"no\" scrolling=\"no\" style=\"width:400px; height:28px;\"></iframe>";
	    strContent += "<div class=\"uploading\" id=\"uploading"+itemid+"\" style=\"display:none;\" ></div>";
	    //strContent += "<div class=\"image\" id=\"panelViewPic"+itemid+"\" style=\"display:none;\"></div></div>";
	    el.append(strContent);
    };
 	
    </script>

    <table border="0" cellpadding="0" cellspacing="0" class="dialog" width="100%">
        <caption>
            <span>上传附件</span></caption>
        <tr>
            <td>
                <div id="toolbox" style="">
                    <a href="#" onclick="uploadcreate($('#uploadbox'));">添加一个新上传控件</a>
                </div>
                <br />
                <div id="uploadbox">
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
